#include "fs_IDPool.h"

fs_IDPool* fs_IDPool::m_instance = NULL;

fs_IDPool *fs_IDPool::Instance(void) {
	if(!m_instance)
		m_instance = new fs_IDPool();

	return m_instance;
}

unsigned int fs_IDPool::getID() {
	if(freeIDs->empty())
		for(int i = 255; i >= 1; --i)
			freeIDs->push_back(unsigned int(i));

	unsigned int id = freeIDs->back();
	freeIDs->pop_back();
	return id;
}

void fs_IDPool::releaseID(unsigned int ID) {
	freeIDs->push_back(ID);
}

void fs_IDPool::Destroy() {
	delete m_instance;
	m_instance = NULL;
}